$class-prefix-input: rt-input;

.#{$class-prefix-input} {
  --font-size: var(--rt-size-14);
  --color: var(--rt-color-text);
  --placeholder-color: var(--rt-color-light);
  --label-color: var(--rt-color-weak);
  --text-align: left;
  --background-color: transparent;

  display: flex;
  justify-content: flex-start;
  align-items: center;
  position: relative;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  min-height: 26px;
  background-color: transparent;

  &-mode-label {
    align-items: flex-end;

    .#{$class-prefix-input}-element {
      margin-top: 40px;
    }
  }

  &-label {
    position: absolute;
    font-size: var(--font-size);
    color: var(--label-color);
    top: 14px;
    transition: 0.3s;
    pointer-events: none;

    &-active {
      font-size: var(--rt-size-12);
      top: 8px;
      color: var(--rt-color-primary);
    }
  }

  &-disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }
}

.#{$class-prefix-input}-element {
  flex: auto;
  display: inline-block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  padding: 0;
  padding-left: 5px;
  margin: 0;
  color: var(--color);
  font-size: var(--font-size);
  line-height: 1.4;
  background: var(--background-color)!important;
  border: 0;
  border-radius: 4px;
  outline: none;
  appearance: none;
  min-height: 2em;
  text-align: var(--text-align);

  &::placeholder {
    color: var(--placeholder-color);
    font-family: inherit;
  }

  &:-webkit-autofill {
    background-color: transparent;
  }

  &:read-only {
    cursor: default;
  }

  &:invalid {
    box-shadow: none;
  }

  &::-ms-clear {
    display: none;
  }

  &::-ms-reveal {
    display: none;
  }

  &::-webkit-search-cancel-button {
    display: none;
  }
  &::-webkit-search-decoration {
    display: none;
  }
  &:disabled {
    opacity: 1;
    -webkit-text-fill-color: var(--color);
  }

  // for ios
  &[type='date'],
  &[type='time'],
  &[type='datetime-local'] {
    min-height: 2em;
  }

  // for safari
  &[type='search'] {
    -webkit-appearance: none;
  }

  // readOnly	❌ 不能编辑	✅ 可以聚焦	✅ 事件正常触发	✅ 值会提交
  // disabled	❌ 不能编辑	❌ 不能聚焦	❌ 事件不触发	❌ 值不提交
  &[readonly] {
    pointer-events: none;
  }
}

.#{$class-prefix-input}-clear {
  flex: none;
  margin-left: 8px;
  color: var(--rt-color-light);
  &:active {
    color: var(--rt-color-weak);
  }
  padding: 2px;
  cursor: pointer;
}

.#{$class-prefix-input}-custom-icon {
  flex: none;
  margin-left: 8px;
  color: var(--rt-color-primary);
  padding: 2px;
  cursor: pointer;
}

